<?php

namespace app\common\model\admin\service_config;

use think\admin\Model;

/**
 *  系统服务配置规则模型
 *
 * @class ServiceConfigRule
 * @package app\common\model\admin\service_config
 * @Author: shirukun
 * @Date: 2024/11/7 16:37
 */
class ServiceConfigRule extends Model
{
    /**
     * 日志名称
     * @var string
     */
    protected $oplogName = '系统配置参数规则';

    /**
     * 日志类型
     * @var string
     */
    protected $oplogType = '系统配置参数规则管理';


    protected $append = ["group_name"];

    /**
     * Desc: 表单类型
     * @return array
     */
    public static function formTypeItems()
    {
        return [
            'string' => lang('字符'),
            'password' => lang('密码'),
            'number' => lang('数值'),
            'datetime' => lang('日期时间'),
            'datetimerange' => lang('日期时间区间'),
            'txt' => lang('文本'),
            'editor' => lang('编辑器'),
            'radio' => lang('单选'),
            'checkbox' => lang('多选'),
            'select' => lang('下拉框'),
            'file' => lang('文件'),
            'pic' => lang('单图'),
            'pics' => lang('多图'),
        ];

    }

    public function getGroupNameAttr($value,$data)
    {
        $group = ServiceConfigTab::mk()->where(['type' => $data['type'],'code' => $data['group']])->column('name','code');
        $groupName = $group[$data['group']] ?? '-';
        return $groupName;
    }


}